package com.ev.apis.controller.mes;

import com.ev.apis.model.DsResultResponse;
import com.ev.framework.annotation.EvApiByToken;
import com.ev.framework.utils.R;
import com.ev.mes.vo.SeOutStockParam;
import com.ev.mes.service.SeOutStockService;
import com.ev.mes.vo.SeOutStockVO;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 姚家乐
 * @since 2021/7/20 11:16
 */
@Api(value = "/", tags = "发货通知单API")
@RestController
public class SeOutStockController {

    @Autowired
    private SeOutStockService service;
    @ApiOperation("获取发货通知单列表信息")
    @EvApiByToken(value = "/apis/seOutStock/list", method = RequestMethod.POST, apiTitle = "获取发货通知单列表信息")
    public R list(@ApiParam(value = "当前第几页", required = true) @RequestParam(value = "pageno", defaultValue = "1") Integer pageno,
                  @ApiParam(value = "一页多少条", required = true) @RequestParam(value = "pagesize", defaultValue = "20") Integer pagesize) {
        SeOutStockParam param = new SeOutStockParam();
        param.setPageNo(pageno);
        param.setPageSize(pagesize);

        Integer total = service.count(param);
        Map<String,Object> result = Maps.newHashMap();
        if (total > 0){
            List<SeOutStockVO> data = service.list(param);
            result.put("data", new DsResultResponse(pageno,pagesize,total,data));
        }
        return R.ok(result);
    }
}
